package errors

type noSqlRow interface {
	noSqlRow() bool
}

type internal interface {
	internal() bool
}

func NoSqlRow() error{
	return &appError{code: 404, reason: "no such row"}
}

func Internal() error {
	return &appError{code: 500, reason: "server internal errors"}
}

func IsNoSqlRow(err error) bool {
	ne, ok := err.(noSqlRow)
	return ok && ne.noSqlRow()
}

func IsInternal(err error) bool {
	ne, ok := err.(internal)
	return ok && ne.internal()
}

func (e *appError)noSqlRow() bool {
	return e.code == 404 && e.reason == "no such row"
}

func (e *appError)internal() bool {
	return e.code == 500 && e.reason == "server internal errors"
}

